package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsRooms;
import com.hbms.business.service.IHotelbmsRoomsService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 客房信息管理Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/rooms")
public class HotelbmsRoomsController extends BaseController
{
    @Autowired
    private IHotelbmsRoomsService hotelbmsRoomsService;

    /**
     * 查询客房信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsRooms hotelbmsRooms)
    {
        startPage();
        List<HotelbmsRooms> list = hotelbmsRoomsService.selectHotelbmsRoomsList(hotelbmsRooms);
        return getDataTable(list);
    }

    /**
     * 导出客房信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:export')")
    @Log(title = "客房信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsRooms hotelbmsRooms)
    {
        List<HotelbmsRooms> list = hotelbmsRoomsService.selectHotelbmsRoomsList(hotelbmsRooms);
        ExcelUtil<HotelbmsRooms> util = new ExcelUtil<HotelbmsRooms>(HotelbmsRooms.class);
        util.exportExcel(response, list, "客房信息管理数据");
    }

    /**
     * 获取客房信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:query')")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return success(hotelbmsRoomsService.selectHotelbmsRoomsByRoomId(roomId));
    }

    /**
     * 新增客房信息管理
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:add')")
    @Log(title = "客房信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsRooms hotelbmsRooms)
    {
        return toAjax(hotelbmsRoomsService.insertHotelbmsRooms(hotelbmsRooms));
    }

    /**
     * 修改客房信息管理
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:edit')")
    @Log(title = "客房信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsRooms hotelbmsRooms)
    {
        return toAjax(hotelbmsRoomsService.updateHotelbmsRooms(hotelbmsRooms));
    }

    /**
     * 删除客房信息管理
     */
    @PreAuthorize("@ss.hasPermi('business:rooms:remove')")
    @Log(title = "客房信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(hotelbmsRoomsService.deleteHotelbmsRoomsByRoomIds(roomIds));
    }
}
